<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;

class Ad extends Model
{
	use HasDateTimeFormatter;

    protected $fillable = [
        'user_id',
        'name',
        'ad_category_id',
        'type',
        'ad_hierarchy_id',
        'area',
        'days',
        'amount',
        'instructions',
        'material',
        'trade_no',
        'grand_id',
        'parent_id',
        'pay_method',
        'platform',
        'direct_distribution_income',
        'interposition_income'
    ];

    protected $attributes = [
        'parent_id' => 0,
        'grand_id' => 0,
        'audit_status' => 1,
        'status' => 1,
        'direct_distribution_income' => 0,
        'interposition_income' => 0,
    ];

    public function user()
    {
        return $this->belongsTo(User::class,'user_id');
    }

    public function category()
    {
        return $this->belongsTo(AdCategory::class,'ad_category_id');
    }

    public function hierarchy()
    {
        return $this->belongsTo(AdHierarchy::class,'ad_hierarchy_id');
    }

}
